home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $VER: GMSignature.thor 0.002 (21.10.99)
- ** © Gian Maria Calzolari <gcalzo@geocities.com>
- **
- ** FUNCTION:
- ** Enhances Thor's signature systems implementing both a random tag
- ** and a specific conference's signature. Default signature allowed.
- **
- ** $HISTORY:
- **
- ** 21 Oct 1999 : 000.002 : Added pattern support for Conference name
- ** 20 Oct 1999 : 000.001 : First attempt, based from mine GMAutoWrite (try it! ;-)
- **
- */
-
- parse upper arg "BBSNAME" BBS "CONFNAME" CNAME .
-
- BBS = strip(compress(BBS,'"'))
- CNAME = strip(compress(CNAME,'"'))
-
- if BBS = "" | CNAME = "" then
- call ExitMsg("GMSignature.thor must be called as Thor's Signature Command")
-
- ConfigFile = 'ENV:Thor/' || BBS || '.cfg'
-
- /* If no Configfile simply exit! */
- if ~Exists(ConfigFile) then
- exit
-
- VerStr = subword(sourceline(2),3)
-
- true = 1
- false = 0
-
- /* This tags can be omitted, default will be "blank" */
- TagOptsBlk = "TagPgm"
-
- /* This tags can be omitted, default will be "zero" */
- TagOptsZro = "TagPgmType"
-
- TagOptions = "SigFile" TagOptsBlk TagOptsZro
- NumOpts = words(TagOptions)
-
- call ReadConfig
-
- call Validate
-
- index = SrcConf(CNAME)
-
- if index = 0 then
- index = SrcConf("DEFAULT")
-
- if Exists(Tags.index.SIGFILE) then
- address command 'type' Tags.index.SIGFILE
- else
- call ExitMsg("'SigFile' '" || Tags.index.SIGFILE || "' not found!")
-
- if Tags.index.TAGPGM ~= '' then do
- say "--"
-
- if Tags.index.TAGPGMTYPE = 0 then /* Arexx */
- Tags.index.TAGPGM
- else /* dos */
- address command Tags.index.TAGPGM
- end
-
- exit
-
- /* ...game over... */
-
-
- Validate:
- DefFound = false
-
- do i = 1 to Tags.0
-
- if upper(Tags.i) = "DEFAULT" then
- DefFound = true
-
- do y = 1 to NumOpts
- Opt = upper(word(TagOptions, y))
- OptDef = symbol('Tags.i.Opt')
-
- Select
- When find(upper(TagOptsBlk),Opt) > 0 then
- if OptDef ~= 'VAR' then Tags.i.Opt = ''
- When find(upper(TagOptsZro),Opt) > 0 then
- if OptDef ~= 'VAR' then Tags.i.Opt = 0
- Otherwise
- if OptDef ~= 'VAR' then call ExitMsg("'" || Opt || "' not defined in tag '" || Tags.i || "'")
- end
-
- end
- end
-
- if ~DefFound then
- call ExitMsg("'DEFAULT' tag not defined in file '" || ConfigFile || "'")
-
- return
-
-
- /* Searches the conference in the config
- ** parm1 conference to be searched
- **
- ** returns the index or 0 if not found
- */
- SrcConf:
- cnfr = arg(1)
-
- do i = 1 to Tags.0
- CONF = cnfr
-
- if Tags.i.PAT = 0 then do
-
- if CONF = Tags.i then return i
-
- end
- else do
- select
- when Tags.i.PAT = 1 then do
- CONF = left(CONF, length(Tags.i))
-
- if CONF = Tags.i then return i
-
- end
- when Tags.i.PAT = 2 then do
- CONF = right(CONF, length(Tags.i))
-
- if CONF = Tags.i then return i
-
- end
- when Tags.i.PAT = 3 then do
-
- if index(CONF, Tags.i) > 0 then return i
-
- end
- end
- end
- end
-
- return 0
-
-
- ReadConfig:
- /* Tags.0 will contains the Conference numbers, Tags.X will be the
- ** Conference name (without the "*" if used...)
- ** Tags.X.y will be defined as follow:
- ** Tags.X.SigFile File to be used as message sign
- ** Tags.X.TagPgm External pgm that will write a tag to stdout
- ** Tags.X.TagPgmType External pgm type (0 = ARexx / 1 = dos)
- ** Tags.X.Pat internal field: 0=no pattern, 1=on right, 2=on left, 3=both
- */
- drop Tags.
- Tags.0 = 0
- TagsNum = 0
-
- CfgOpen = open(cfgfile,ConfigFile,'r')
-
- if ~(CfgOpen) then call ExitMsg('Reading: failed to open' ConfigFile)
-
- do until eof(cfgfile)
- nextline = readln(cfgfile)
-
- if compress(nextline) = "" then iterate
-
- parse var nextline CfgName CfgVal
- CfgName = upper(CfgName)
- CfgVal = strip(compress(CfgVal,'"'))
-
- if CfgName = 'TAG' then do
- TagsNum = TagsNum + 1
-
- pattern = 0
-
- if right(CfgVal,1) = '*' then
- pattern = pattern +1
-
- if left(CfgVal,1) = '*' then
- pattern = pattern +2
-
- CfgVal = compress(CfgVal,'*')
- Tags.TagsNum.PAT = pattern
-
- Tags.TagsNum = upper(CfgVal)
- end
- else do
-
- if TagsNum = 0 then call ExitMsg('No Tag names found!')
-
- if find(upper(TagOptions), CfgName) > 0 then
- Tags.TagsNum.CfgName = CfgVal
- else
- call ExitMsg("Option '" || CfgName || "' (with value '" || CfgVal || "') in tag '" || Tags.TagsNum || "' not allowed!")
- end
- end
-
- if TagsNum = 0 then call ExitMsg('No Tag names found!')
-
- Tags.0 = TagsNum
-
- if (CfgOpen) then dummy = close(cfgfile)
- return
-
-
-
- /* Exit with a message */
- ExitMsg:
- parse arg msgstr
- address command
- 'RequestChoice >NIL: "GMSignature.thor" "'msgstr'" "OK :-("'
- exit
-
-